package com.ywh.composetest.activity

import android.os.Bundle
import android.util.Log
import androidx.activity.ComponentActivity
import androidx.compose.runtime.Composable
import com.ywh.composetest.DataClass
import com.ywh.composetest.DataClass2
import com.ywh.composetest.MyClass
import com.ywh.composetest.MyClass3
import com.ywh.composetest.SealedClass

class ParcelizeActivity : BaseComposeActivity() {

    @Composable
    override fun OnComposable(savedInstanceState: Bundle?) {
        val dataClass = intent?.getParcelableExtra<DataClass>("dataClass")
        Log.e("KotlinParcelize", "dataClass:${dataClass.toString()}")

        val dataClass2 = intent?.getParcelableExtra<DataClass2>("dataClass2")
        Log.e("KotlinParcelize", "dataClass2:${dataClass2.toString()}")

        val myClass = intent?.getParcelableExtra<MyClass>("myClass")
        Log.e("KotlinParcelize", "myClass:${myClass.toString()}")

        val sealedClassA = intent?.getParcelableExtra<SealedClass.A>("sealedClassA")
        Log.e("KotlinParcelize", "sealedClassA:${sealedClassA?.name1}")

        val sealedClassB = intent?.getParcelableExtra<SealedClass>("sealedClassB")
        Log.e("KotlinParcelize", "sealedClassB:${(sealedClassB as SealedClass.B).age}")

        val sealedClassC = intent?.getParcelableExtra<SealedClass>("sealedClassC")
        Log.e("KotlinParcelize", "sealedClassC:${(sealedClassC is SealedClass.C)}")

        val external = intent?.getParcelableExtra<MyClass3>("external")
        Log.e("KotlinParcelize", "external:${external?.external.hashCode()},${external?.external.toString()}")
    }
}
